﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Collections.Generic;
using System.Text;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Web;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting;
using System.Web.Services;
using System.IO;
using System.Collections;
using System.ServiceModel.Activation;
using System.ServiceModel.Description;
using System.Threading;
using System.Diagnostics;
using System.Reflection;
using System.Web.SessionState;

using PickGold.Base.Proxies;

namespace PickGold.Base.Remoting
{
	class MethodInvokerLocaleProxy<API> : MethodInvokerProxy where API : class
	{
		protected API InnerProxy;//IMethodInvoker

		public MethodInvokerLocaleProxy(API real) : base(typeof(API))
		{
			this.InnerProxy = real;
		}

		public override IMessage Invoke(IMessage msg)
		{
			//this.Running++;
			this.Message = msg as IMethodMessage;
			msg = MethodInvokerRemoteRealProxy.LocalInvoke<API>(this.InnerProxy, this.Items, msg, this.EventList[InvokingKey] as InvokeMessageEventHandler);
			this.Message = msg as IMethodMessage;
			//this.Running--;
			return msg;
		}

		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);
			this.InnerProxy = null;
		}
	}
}
